00001
00002
00003
00004
00005
00006
00007
00008 #include "stdafx.h"
00009 #include "TraffEdu.h"
00010 #include "Splitter.h"
00011
00012 #ifdef _DEBUG
00013 #define new DEBUG_NEW
00014 #undef THIS_FILE
00015 static char THIS_FILE[] = __FILE__;
00016 #endif
00017
00019
00020
00021 C4WaySplitter::C4WaySplitter()
00022 {
00023
00024 m_BkColor = RGB(128,128,128);
00025 m_ListBoxBkBrush.CreateSolidBrush(m_BkColor);
00026 m_nHiddenCol=-1;
00027 m_nHidedCol=-1;
00028 m_nHidedRow=-1;
00029 }
00030
00031 C4WaySplitter::~C4WaySplitter()
00032 {
00033 m_ListBoxBkBrush.DeleteObject();
00034 }
00035
00036
00037 BEGIN_MESSAGE_MAP(C4WaySplitter, CSplitterWnd)
00038
00039 ON_WM_CTLCOLOR()
00040
00041 END_MESSAGE_MAP()
00042
00043 HBRUSH C4WaySplitter::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
00044 {
00045 HBRUSH hbr = CSplitterWnd::OnCtlColor(pDC, pWnd, nCtlColor);
00046
00047 if( nCtlColor == CTLCOLOR_LISTBOX &&
00048 pWnd->GetDlgCtrlID() == IdFromRowCol(1,0) )
00049 {
00050 pDC->SetBkColor(m_BkColor);
00051 pDC->SetTextColor(RGB(255,255,255));
00052 return ( HBRUSH ) m_ListBoxBkBrush.GetSafeHandle();
00053 }
00054
00055 return hbr;
00056 }
00057
00058 BOOL C4WaySplitter::ReplaceView(CRuntimeClass* pRTClass)
00059 {
00060 TRACE("inside Splitter::ReplaceView\n");
00061 CTraffEduDoc* pDoc = ((CTraffEduApp*)AfxGetApp())->m_pDoc;
00062 if(!pDoc)
00063 {
00064 AfxMessageBox("There was a problem reading the file, please open another one.");
00065 return FALSE;
00066 }
00067
00068 CWnd* pWndLeftPane = GetPane(0,0);
00069 if(pWndLeftPane->IsKindOf(pRTClass))
00070 return FALSE;
00071
00072
00073
00074 pDoc->m_bAutoDelete = FALSE;
00075
00076
00077 pWndLeftPane->DestroyWindow();
00078
00079
00080 CCreateContext context;
00081 context.m_pNewViewClass = pRTClass;
00082 context.m_pCurrentDoc = pDoc;
00083 context.m_pNewDocTemplate = NULL;
00084 context.m_pLastView = NULL;
00085 context.m_pCurrentFrame = NULL;
00086 CreateView(0, 0, pRTClass, CSize(120,120), &context);
00087
00088 CView* pNewView = (CView*)GetPane(0,0);
00089 RecalcLayout();
00090 pNewView->OnInitialUpdate();
00091 pNewView->SendMessage(WM_PAINT);
00092
00093 return TRUE;
00094 }